home *** CD-ROM | disk | FTP | other *** search
/ Computer Arts: Pro Software Skills - Photoshop / Computer Arts Pro Software Skills Photoshop.iso / pc / main.fla / bin / vvbk9lpjbp.swf / scripts / frame_1 / DoAction.as
Encoding:
Text File  |  2011-05-24  |  6.7 KB  |  306 lines

  1. function onLoad()
  2. {
  3.    if(typeof _root.instanceID == "undefined")
  4.    {
  5.       contents.obj.setSize(Stage.width,Stage.height);
  6.    }
  7. }
  8. function nextChar()
  9. {
  10.    return str.charAt(strIndex);
  11. }
  12. function isSpace(ch)
  13. {
  14.    return ch == " " || ch == "\t" || ch == "\r" || ch == "\n";
  15. }
  16. function trimSpaces(s)
  17. {
  18.    var _loc1_ = undefined;
  19.    var _loc3_ = undefined;
  20.    _loc1_ = 0;
  21.    while(_loc1_ < s.length)
  22.    {
  23.       if(!isSpace(s.charAt(_loc1_)))
  24.       {
  25.          break;
  26.       }
  27.       _loc1_ = _loc1_ + 1;
  28.    }
  29.    _loc3_ = s.length;
  30.    while(_loc3_ > 0)
  31.    {
  32.       if(!isSpace(s.charAt(_loc3_ - 1)))
  33.       {
  34.          break;
  35.       }
  36.    }
  37.    return s.substring(_loc1_,_loc3_);
  38. }
  39. function skipSpaces()
  40. {
  41.    var _loc1_ = undefined;
  42.    while(isSpace(nextChar()))
  43.    {
  44.       strIndex++;
  45.    }
  46. }
  47. function parseArray()
  48. {
  49.    var _loc3_ = [];
  50.    skipSpaces();
  51.    if(nextChar() == "]")
  52.    {
  53.       strIndex++;
  54.       return _loc3_;
  55.    }
  56.    while(true)
  57.    {
  58.       skipSpaces();
  59.       var _loc2_ = parse();
  60.       _loc3_.push(_loc2_);
  61.       skipSpaces();
  62.       var _loc1_ = nextChar();
  63.       if(_loc1_ == "]")
  64.       {
  65.          strIndex++;
  66.          break;
  67.       }
  68.       if(_loc1_ != ",")
  69.       {
  70.          break;
  71.       }
  72.       strIndex++;
  73.    }
  74.    return _loc3_;
  75. }
  76. function parseObject()
  77. {
  78.    var _loc5_ = {};
  79.    skipSpaces();
  80.    var _loc2_ = nextChar();
  81.    if(_loc2_ == undefined)
  82.    {
  83.       return _loc5_;
  84.    }
  85.    if(_loc2_ == "}")
  86.    {
  87.       strIndex++;
  88.       return _loc5_;
  89.    }
  90.    while(true)
  91.    {
  92.       skipSpaces();
  93.       var _loc1_ = str.indexOf(":",strIndex);
  94.       if(_loc1_ == -1)
  95.       {
  96.          break;
  97.       }
  98.       var _loc4_ = str.substring(strIndex,_loc1_);
  99.       strIndex = _loc1_ + 1;
  100.       var _loc3_ = parse();
  101.       _loc5_[_loc4_] = _loc3_;
  102.       skipSpaces();
  103.       _loc2_ = nextChar();
  104.       if(_loc2_ == "}")
  105.       {
  106.          strIndex++;
  107.          break;
  108.       }
  109.       if(_loc2_ != ",")
  110.       {
  111.          break;
  112.       }
  113.       strIndex++;
  114.    }
  115.    return _loc5_;
  116. }
  117. function parseString()
  118. {
  119.    var _loc2_ = "";
  120.    var _loc1_ = undefined;
  121.    while((_loc1_ = str.indexOf("\'",strIndex)) != -1)
  122.    {
  123.       if(str.charAt(_loc1_ - 1) != "\\")
  124.       {
  125.          break;
  126.       }
  127.       _loc2_ += str.substring(strIndex,_loc1_ - 1);
  128.       _loc2_ += "\'";
  129.       strIndex = _loc1_ + 1;
  130.    }
  131.    _loc2_ += str.substring(strIndex,_loc1_);
  132.    strIndex = _loc1_ + 1;
  133.    return _loc2_;
  134. }
  135. function parse()
  136. {
  137.    skipSpaces();
  138.    var _loc1_ = nextChar();
  139.    if(_loc1_ == "{")
  140.    {
  141.       strIndex++;
  142.       return parseObject();
  143.    }
  144.    if(_loc1_ == "[")
  145.    {
  146.       strIndex++;
  147.       return parseArray();
  148.    }
  149.    if(_loc1_ == "\'")
  150.    {
  151.       strIndex++;
  152.       return parseString();
  153.    }
  154.    var _loc2_ = strIndex;
  155.    while(true)
  156.    {
  157.       _loc1_ = str.charAt(_loc2_);
  158.       if(_loc1_ == undefined || _loc1_ == "}" || _loc1_ == "]" || _loc1_ == ",")
  159.       {
  160.          break;
  161.       }
  162.       _loc2_ = _loc2_ + 1;
  163.    }
  164.    var _loc3_ = trimSpaces(str.substring(strIndex,_loc2_));
  165.    strIndex = _loc2_;
  166.    if(_loc3_.charAt(0) == "#" && _loc3_.length == 7)
  167.    {
  168.       _loc3_ = "0x" + _loc3_.substring(1,7);
  169.    }
  170.    if(_loc3_ == "true")
  171.    {
  172.       return true;
  173.    }
  174.    if(_loc3_ == "false")
  175.    {
  176.       return false;
  177.    }
  178.    return Number(_loc3_);
  179. }
  180. function onSizeMulti()
  181. {
  182.    var _loc3_ = "instance" + _root.instanceID;
  183.    var _loc2_ = contents[_loc3_];
  184.    _root.instanceWidth = Number(_root.instanceWidth);
  185.    _root.instanceHeight = Number(_root.instanceHeight);
  186.    if(_loc2_.width != _root.instanceWidth || _loc2_.height != _root.instanceHeight)
  187.    {
  188.       _loc2_.setSize(_root.instanceWidth,_root.instanceHeight);
  189.       if(typeof _loc2_._livePreviewMask == "undefined")
  190.       {
  191.          _loc2_._livePreviewMask = _root.createEmptyMovieClip("_livePreviewMask" + instanceID,1);
  192.          _loc2_.setMask(_loc2_._livePreviewMask);
  193.       }
  194.       _loc2_._livePreviewMask.clear();
  195.       _loc2_._livePreviewMask.beginFill(0,100);
  196.       _loc2_._livePreviewMask.moveTo(0,0);
  197.       _loc2_._livePreviewMask.lineTo(_root.instanceWidth,0);
  198.       _loc2_._livePreviewMask.lineTo(_root.instanceWidth,_root.instanceHeight);
  199.       _loc2_._livePreviewMask.lineTo(0,_root.instanceHeight);
  200.       _loc2_._livePreviewMask.lineTo(0,0);
  201.       _loc2_._livePreviewMask.endFill();
  202.       _loc2_._visible = true;
  203.       _loc2_._x = 0;
  204.       _loc2_._y = 0;
  205.    }
  206. }
  207. function onDrawMulti()
  208. {
  209.    if(_root.visibleID != _root.instanceID)
  210.    {
  211.       contents.obj._visible = false;
  212.       if(typeof _root.visibleID != "undefined")
  213.       {
  214.          contents["instance" + _root.visibleID]._visible = false;
  215.       }
  216.       contents["instance" + _root.instanceID]._visible = true;
  217.       _root.visibleID = _root.instanceID;
  218.    }
  219. }
  220. function onUpdateMulti()
  221. {
  222.    var _loc6_ = "instance" + _root.instanceID;
  223.    if(!contents[_loc6_])
  224.    {
  225.       var _loc5_ = {};
  226.       for(var _loc8_ in xch)
  227.       {
  228.          var _loc2_ = String(_loc8_);
  229.          if(_loc2_.indexOf("def_",0) == 0)
  230.          {
  231.             _loc2_ = _loc2_.substring(4);
  232.          }
  233.          _loc5_[_loc2_] = xch[_loc8_];
  234.       }
  235.       contents.obj.duplicateMovieClip(_loc6_,_root.instanceID + 100,_loc5_);
  236.       contents[_loc6_]._visible = false;
  237.    }
  238.    else
  239.    {
  240.       var _loc3_ = contents[_loc6_];
  241.       for(_loc8_ in xch)
  242.       {
  243.          _loc2_ = String(_loc8_);
  244.          if(_loc2_.indexOf("def_",0) == 0)
  245.          {
  246.             _loc2_ = _loc2_.substring(4);
  247.          }
  248.          _loc3_[_loc2_] = xch[_loc8_];
  249.       }
  250.       if(_root.flashlet)
  251.       {
  252.          str = unescape(_root.flashlet);
  253.          strIndex = 0;
  254.          var _loc4_ = parse();
  255.          for(var _loc7_ in _loc4_)
  256.          {
  257.             _loc3_[_loc7_] = _loc4_[_loc7_];
  258.          }
  259.       }
  260.       _loc3_.onUpdate();
  261.    }
  262. }
  263. function onUpdate()
  264. {
  265.    if(typeof _root.instanceID != "undefined")
  266.    {
  267.       return onUpdateMulti();
  268.    }
  269.    for(var _loc5_ in xch)
  270.    {
  271.       var _loc2_ = String(_loc5_);
  272.       if(_loc2_.indexOf("def_",0) == 0)
  273.       {
  274.          _loc2_ = _loc2_.substring(4);
  275.       }
  276.       contents.obj[_loc2_] = xch[_loc5_];
  277.    }
  278.    if(_root.flashlet)
  279.    {
  280.       str = unescape(_root.flashlet);
  281.       strIndex = 0;
  282.       var _loc3_ = parse();
  283.       for(var _loc4_ in _loc3_)
  284.       {
  285.          contents.obj[_loc4_] = _loc3_[_loc4_];
  286.       }
  287.    }
  288.    contents.obj.onUpdate();
  289. }
  290. Stage.align = "TL";
  291. Stage.scaleMode = "noScale";
  292. listen = new Object();
  293. Stage.addListener(listen);
  294. _global.isLivePreview = true;
  295. listen.onResize = function()
  296. {
  297.    if(typeof _root.instanceID == "undefined")
  298.    {
  299.       contents.obj.setSize(Stage.width,Stage.height);
  300.    }
  301. };
  302. if(_root.flashlet)
  303. {
  304.    onUpdate();
  305. }
  306.